package init

import (
	"api-gatway/basic/config"
	__ "api-gatway/basic/proto"
	"flag"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"log"
)

func InitGrpc() {
	//consulClient := utils.NewConsul("14.103.101.210:8500")
	//userServiceCfg := &utils.ServiceConfig{
	//	Name: "user-service",
	//	Addr: "127.0.0.1",
	//	Port: 50051,
	//	Tags: []string{"user-service"},
	//}
	//
	//if err := consulClient.RegisterService(userServiceCfg); err != nil {
	//	panic("user-srv 服务注册失败")
	//}
	flag.Parse()
	// Set up a connection to the server.
	conn, err := grpc.NewClient("127.0.0.1:50052", grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}

	config.UserClient = __.NewUserClient(conn)
	config.VideoClient = __.NewVideoClient(conn)
}
